package com.itheima.app.controller;

import com.itheima.app.manager.MakeFriendManager;
import com.itheima.app.manager.UserLikeManager;
import com.itheima.vo.PageBeanVo;
import com.itheima.vo.UserLikeCountVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Guanxing
 * @date 2021/9/28
 */
@RestController
public class UserLikeController {

    @Autowired
    private UserLikeManager userLikeManager;

    //喜欢
    @GetMapping("/tanhua/{id}/love")
    public void saveUserLike(
            @PathVariable("id") Long userLikeId

    ){
        userLikeManager.saveUserLike(userLikeId);
    }

    //用户不喜欢
    @GetMapping("/tanhua/{id}/unlove")
    public void deleteUserLike(@PathVariable("id") Long likeUserId){
        userLikeManager.deleteUserLike(likeUserId);
    }

    //查询我的互相喜欢、喜欢、粉丝数量
    @GetMapping("/users/counts")
    public UserLikeCountVo usersCounts(){
        return  userLikeManager.usersCounts();
    }

    /**
     * 查询 互相喜欢，喜欢，粉丝 访客 数据
     * 1 互相关注
     * 2 我关注
     * 3 粉丝
     * 4 谁看过我
     * @param page
     * @param pageSize
     * @param type
     * @return
     */
    @GetMapping("/users/friends/{type}")
    public PageBeanVo findUserInfoByType(
            @RequestParam(defaultValue = "1") Integer page ,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @PathVariable String type
    ){
        return userLikeManager.findUserInfoByType(page,pageSize,type);
    }

    //粉丝-喜欢
    @PostMapping("/users/fans/{uid}")
    public void saveFanLike(@PathVariable("uid") Long uid) {
        userLikeManager.saveUserLike(uid);
    }

    //互相喜欢-取消喜欢
    @DeleteMapping("/users/like/{uid}")
    public void deleteLike(@PathVariable("uid") Long uid) {
        userLikeManager.deleteUserLike(uid);
    }
}


